package com.RuiJi.controller;

import com.RuiJi.entity.Dish;
import com.RuiJi.entity.OrderDetail;
import com.RuiJi.entity.Orders;
import com.RuiJi.service.Impl.OrderServiceImpl;
import com.RuiJi.service.OrderService;
import com.RuiJi.utils.R;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sun.org.apache.xpath.internal.operations.Or;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.Period;

/**
 * @author Twinkle
 * @NAME: OrderController
 * @DATE: 2023/4/19/0:17
 * @YEAR: 2023/04
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderServiceImpl orderService;

    @PostMapping("/submit")
    public R<String> submit(@RequestBody Orders orders){
        orderService.submit(orders);
        return R.success("下单成功");
    }



    @GetMapping("/userPage")
    public R<Page> userpage( int page,int pageSize){
        Page<OrderDetail> ordersPage =new Page<>(page,pageSize);
        LambdaQueryWrapper<OrderDetail> queryWrapper =new LambdaQueryWrapper<>();
        queryWrapper.orderByAsc(OrderDetail::getOrderId);
        return R.success(ordersPage);
    }

}
